package com.huang.order;

import com.huang.api.service.UserService;
import com.huang.common.core.context.SecurityContextHolder;
import com.huang.common.core.domain.R;
import com.huang.order.service.OrderService;
import com.huang.security.annotation.RequiresPermissions;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 黄自祥
 * @date 2023/01/10 20:40
 * @Description:
 */

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    OrderService orderService;

    @Autowired
    public UserService userService;


    @PostMapping("/seataTest")
    public void orderService(@RequestBody Map map) throws Exception {
        orderService.seataTest(map);
    }

    @RequiresPermissions("tool:gen:list")
    @RequestMapping("/getUser")
    public String getUser(){
        String userName = SecurityContextHolder.getUserName();
        System.out.println(userName);
        return userService.getUser();
    }

    @RequiresPermissions("tool:huang:permissions")
    @RequestMapping("/testPermissions")
    public R<?> testPermissions(){
        return R.ok(true);
    }
}
